package cn.itcast.nems.common.web.util;

import jakarta.servlet.http.HttpServletRequest;

/**
 * author: yong.li
 * create: 2023-09-14 10:30:30
 **/
public class RequestUtil {
    private static final String CLIENT_ID = "clientId";
    private static final String USER_ID = "clientId";

    /**
     * 获取请求的clientId；针对后端之间跨网关调用（OAuth2 client credentials）
     *
     * @param request
     * @return 发起调用端的ID（Keyclock中配置的ID）
     */
    public static String getUserId(HttpServletRequest request) {
        return request.getHeader(CLIENT_ID);
    }

    /**
     * 获取请求的clientId；针对后端之间跨网关调用（OAuth2 client credentials）
     *
     * @param request
     * @return 发起调用端的ID（Keyclock中配置的ID）
     */
    public static String getClientId(HttpServletRequest request) {
        return request.getHeader(CLIENT_ID);
    }
}
